Skip to content

fix: count the calls of an HttpClient separately from those of its handler - #1023

Merged
vbreuss merged 1 commit into
mainfrom
fix/httpclient-handler-member-ids
Nov 18, 2026
Merged

vbreuss merged 1 commit into
mainfrom
fix/httpclient-handler-member-ids

Conversation

@vbreuss

@vbreuss vbreuss commented Nov 18, 2026

Copy link
Copy Markdown
Member

The client mock shares the registry of its handler mock and both numbered their members from zero. As both declare SendAsync with the same parameters, a verification on one also counted the calls of the other. The client now numbers its members after those of the handler.

…ndler

The client mock shares the registry of its handler mock and both numbered their members from zero. As both declare SendAsync with the same parameters, a verification on one also counted the calls of the other. The client now numbers its members after those of the handler.
@vbreuss vbreuss self-assigned this Nov 18, 2026
@vbreuss vbreuss added the bug Something isn't working label Nov 18, 2026
@vbreuss
vbreuss enabled auto-merge (squash) November 18, 2026 14:14
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Test Results

    34 files      34 suites   47m 43s ⏱️
 4 816 tests  4 816 ✅ 0 💤 0 ❌
35 207 runs  35 207 ✅ 0 💤 0 ❌

Results for commit 83c0b99.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🚀 Benchmark Results

Compared to main @​ 7bf0cfd3: memory to the latest run, time to the median of the last 10 runs, as the runners differ in speed. A relative change marks when Mockolate gets more than 15% faster or slower relative to Imposter and TUnitMocks: 🔴 / 🟢 against both of them, 🔸 / 🔹 against only one.

CallbackBenchmarks

✅ No changes in memory or relative performance (1 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Callback 189.2 ns → 134.4 ns (-29%) 792 B → 792 B 0.94× → 1.02× 2.28× → 2.59×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V45 4.19GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Callback Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 134.4 ns 5.81 ns 5.15 ns 1.00 792 B 1.00
Imposter 137.3 ns 3.08 ns 2.57 ns 1.02 616 B 0.78
TUnitMocks 348.6 ns 8.00 ns 7.49 ns 2.60 2056 B 2.60
Moq 32,177.6 ns 787.71 ns 698.28 ns 239.80 9055 B 11.43
NSubstitute 2,672.6 ns 38.77 ns 32.37 ns 19.92 7864 B 9.93
FakeItEasy 2,630.3 ns 86.03 ns 76.26 ns 19.60 6930 B 8.75

CompleteEventBenchmarks

Relative performance (how many times as long the other library takes as Mockolate, main → PR)

Benchmark vs Imposter vs TUnitMocks
Event 1.08× → 1.30× 🔹 -17% 1.09× → 1.13×
All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Event 159.0 ns → 80.2 ns (-50%) 696 B → 696 B 1.08× → 1.30× 🔹 -17% 1.09× → 1.13×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V45 4.31GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Event Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 80.15 ns 1.271 ns 1.061 ns 1.00 696 B 1.00
Imposter 104.48 ns 3.068 ns 2.720 ns 1.30 512 B 0.74
TUnitMocks 90.33 ns 1.664 ns 1.557 ns 1.13 1392 B 2.00
Moq 7,221.86 ns 204.779 ns 191.551 ns 90.12 12760 B 18.33
NSubstitute 2,837.97 ns 133.435 ns 124.815 ns 35.41 9192 B 13.21
FakeItEasy 109,964.16 ns 2,733.489 ns 2,423.167 ns 1,372.19 15619 B 22.44

CompleteIndexerBenchmarks

✅ No changes in memory or relative performance (3 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Indexer (N=1) 440.3 ns → 497.1 ns (+13%) 1,648 B → 1,648 B 0.63× → 0.60× 1.55× → 1.52×
Indexer (N=10) 1.39 μs → 1.40 μs (+1%) 2,584 B → 2,584 B 0.52× → 0.58× 1.70× → 1.89×
Indexer (N=1000) 105.62 μs → 99.67 μs (-6%) 105,545 B → 105,545 B 0.48× → 0.50× 1.84× → 1.88×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 3.03GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Indexer N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 497.1 ns 16.90 ns 14.98 ns 1.00 1.61 KB 1.00
Imposter 1 300.0 ns 3.79 ns 3.55 ns 0.60 1.07 KB 0.67
TUnitMocks 1 757.3 ns 12.93 ns 12.09 ns 1.52 2.72 KB 1.69
Moq 1 231,036.8 ns 2,065.52 ns 1,724.80 ns 465.13 20.32 KB 12.62
NSubstitute 1 9,892.8 ns 62.18 ns 58.17 ns 19.92 12.78 KB 7.94
FakeItEasy 1 10,694.7 ns 137.18 ns 128.32 ns 21.53 13.27 KB 8.25
Mockolate 10 1,400.8 ns 9.41 ns 7.86 ns 1.00 2.52 KB 1.00
Imposter 10 816.0 ns 6.12 ns 5.72 ns 0.58 2.13 KB 0.84
TUnitMocks 10 2,643.4 ns 16.40 ns 13.69 ns 1.89 5.37 KB 2.13
Moq 10 247,569.8 ns 2,235.28 ns 2,090.88 ns 176.74 29.68 KB 11.76
NSubstitute 10 25,142.3 ns 56.22 ns 52.58 ns 17.95 25.58 KB 10.14
FakeItEasy 10 24,182.8 ns 217.21 ns 203.18 ns 17.26 32.47 KB 12.87
Mockolate 1000 99,671.7 ns 909.99 ns 851.21 ns 1.00 103.07 KB 1.00
Imposter 1000 49,418.6 ns 411.45 ns 364.74 ns 0.50 118.15 KB 1.15
TUnitMocks 1000 187,035.4 ns 1,577.22 ns 1,398.17 ns 1.88 293.67 KB 2.85
Moq 1000 1,063,519.3 ns 5,022.02 ns 4,451.89 ns 10.67 1006.46 KB 9.76
NSubstitute 1000 1,683,467.9 ns 8,442.80 ns 7,897.40 ns 16.89 1465.65 KB 14.22
FakeItEasy 1000 1,469,566.9 ns 16,088.63 ns 15,049.31 ns 14.75 2153 KB 20.89

CompleteMethodBenchmarks

✅ No changes in memory or relative performance (3 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Method (N=1) 125.7 ns → 135.2 ns (+8%) 600 B → 600 B 1.15× → 1.22× 2.98× → 3.33×
Method (N=10) 324.9 ns → 378.0 ns (+16%) 1,104 B → 1,104 B 0.93× → 0.91× 3.52× → 3.45×
Method (N=1000) 22.51 μs → 26.52 μs (+18%) 56,544 B → 56,544 B 0.77× → 0.78× 3.68× → 3.62×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 3.19GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Method N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 135.2 ns 6.27 ns 5.24 ns 1.00 600 B 1.00
Imposter 1 165.0 ns 3.77 ns 3.15 ns 1.22 728 B 1.21
TUnitMocks 1 450.5 ns 6.00 ns 5.61 ns 3.34 2088 B 3.48
Moq 1 193,158.9 ns 858.79 ns 761.30 ns 1,430.14 14902 B 24.84
NSubstitute 1 5,898.7 ns 16.07 ns 12.55 ns 43.67 9320 B 15.53
FakeItEasy 1 5,706.4 ns 52.87 ns 49.46 ns 42.25 8160 B 13.60
Mockolate 10 378.0 ns 4.14 ns 3.87 ns 1.00 1104 B 1.00
Imposter 10 345.4 ns 4.70 ns 4.39 ns 0.91 1088 B 0.99
TUnitMocks 10 1,304.9 ns 10.41 ns 9.74 ns 3.45 3840 B 3.48
Moq 10 197,005.5 ns 606.61 ns 537.74 ns 521.23 18901 B 17.12
NSubstitute 10 8,987.8 ns 69.72 ns 65.22 ns 23.78 12345 B 11.18
FakeItEasy 10 9,352.2 ns 108.69 ns 96.35 ns 24.74 16393 B 14.85
Mockolate 1000 26,522.6 ns 406.70 ns 380.43 ns 1.00 56544 B 1.00
Imposter 1000 20,640.5 ns 257.00 ns 240.40 ns 0.78 40688 B 0.72
TUnitMocks 1000 96,036.1 ns 1,400.36 ns 1,309.90 ns 3.62 203585 B 3.60
Moq 1000 386,168.2 ns 4,033.58 ns 3,773.01 ns 14.56 431938 B 7.64
NSubstitute 1000 270,458.0 ns 592.30 ns 462.43 ns 10.20 378038 B 6.69
FakeItEasy 1000 342,755.5 ns 1,931.66 ns 1,613.02 ns 12.93 944362 B 16.70

CompletePropertyBenchmarks

Relative performance (how many times as long the other library takes as Mockolate, main → PR)

Benchmark vs Imposter vs TUnitMocks
Property (N=10) 0.51× → 0.62× 🔹 -18% 2.41× → 2.78×
Property (N=1000) 0.38× → 0.55× 🟢 -31% 2.69× → 3.32× 🟢 -19%
All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Property (N=1) 221.9 ns → 169.2 ns (-24%) 904 B → 904 B 0.65× → 0.69× 1.68× → 1.74×
Property (N=10) 562.7 ns → 426.3 ns (-24%) 1,768 B → 1,768 B 0.51× → 0.62× 🔹 -18% 2.41× → 2.78×
Property (N=1000) 37.46 μs → 28.82 μs (-23%) 96,808 B → 96,808 B 0.38× → 0.55× 🟢 -31% 2.69× → 3.32× 🟢 -19%
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V45 4.31GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Property N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 169.2 ns 3.54 ns 2.96 ns 1.00 904 B 1.00
Imposter 1 117.0 ns 3.08 ns 2.88 ns 0.69 672 B 0.74
TUnitMocks 1 294.0 ns 5.09 ns 4.51 ns 1.74 1672 B 1.85
Moq 1 5,644.3 ns 80.95 ns 71.76 ns 33.36 10712 B 11.85
NSubstitute 1 3,954.9 ns 44.31 ns 37.00 ns 23.38 11664 B 12.90
FakeItEasy 1 3,857.0 ns 117.93 ns 110.31 ns 22.80 11196 B 12.38
Mockolate 10 426.3 ns 4.67 ns 4.14 ns 1.00 1768 B 1.00
Imposter 10 265.1 ns 5.56 ns 4.64 ns 0.62 960 B 0.54
TUnitMocks 10 1,185.8 ns 21.23 ns 18.82 ns 2.78 4024 B 2.28
Moq 10 9,247.3 ns 134.79 ns 112.56 ns 21.70 18649 B 10.55
NSubstitute 10 9,136.0 ns 128.86 ns 114.23 ns 21.44 21529 B 12.18
FakeItEasy 10 9,516.3 ns 174.87 ns 155.02 ns 22.33 30785 B 17.41
Mockolate 1000 28,817.1 ns 690.53 ns 612.14 ns 1.00 96808 B 1.00
Imposter 1000 15,844.0 ns 271.83 ns 254.27 ns 0.55 32641 B 0.34
TUnitMocks 1000 95,775.7 ns 1,960.37 ns 1,737.81 ns 3.32 242489 B 2.50
Moq 1000 379,463.1 ns 6,579.97 ns 6,154.91 ns 13.17 836681 B 8.64
NSubstitute 1000 568,299.2 ns 10,352.87 ns 9,177.55 ns 19.73 1139697 B 11.77
FakeItEasy 1000 741,039.2 ns 14,822.30 ns 13,864.78 ns 25.73 2194325 B 22.67

CompleteUnconfiguredBenchmarks

✅ No changes in memory or relative performance (3 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Unconfigured (N=1) 457.4 ns → 499.6 ns (+9%) 1,512 B → 1,512 B 0.49× → 0.56× 1.00× → 1.13×
Unconfigured (N=10) 1.67 μs → 1.86 μs (+12%) 3,984 B → 3,984 B 0.49× → 0.54× 1.69× → 1.81×
Unconfigured (N=1000) 138.59 μs → 146.98 μs (+6%) 273,265 B → 273,265 B 0.51× → 0.58× 1.99× → 2.20×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 3.02GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Unconfigured N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 499.6 ns 15.27 ns 12.75 ns 1.00 1.48 KB 1.00
Imposter 1 281.9 ns 5.62 ns 5.25 ns 0.56 1.06 KB 0.72
TUnitMocks 1 564.9 ns 15.86 ns 14.84 ns 1.13 1.81 KB 1.23
Moq 1 116,891.9 ns 1,004.94 ns 940.02 ns 234.13 9.79 KB 6.63
NSubstitute 1 7,642.6 ns 87.94 ns 82.26 ns 15.31 10.01 KB 6.78
FakeItEasy 1 7,638.1 ns 116.01 ns 108.52 ns 15.30 11.58 KB 7.84
Mockolate 10 1,858.4 ns 42.16 ns 39.44 ns 1.00 3.89 KB 1.00
Imposter 10 997.9 ns 12.27 ns 11.48 ns 0.54 2.89 KB 0.74
TUnitMocks 10 3,356.2 ns 75.72 ns 70.83 ns 1.81 8.47 KB 2.18
Moq 10 132,274.7 ns 985.88 ns 922.19 ns 71.21 24.53 KB 6.30
NSubstitute 10 24,734.1 ns 108.66 ns 101.64 ns 13.31 22.93 KB 5.89
FakeItEasy 10 30,404.7 ns 352.99 ns 330.19 ns 16.37 53.92 KB 13.86
Mockolate 1000 146,984.2 ns 1,325.49 ns 1,239.86 ns 1.00 266.86 KB 1.00
Imposter 1000 84,989.7 ns 868.67 ns 678.20 ns 0.58 203.99 KB 0.76
TUnitMocks 1000 322,756.7 ns 7,775.61 ns 7,273.31 ns 2.20 691.21 KB 2.59
Moq 1000 1,659,001.9 ns 14,710.54 ns 13,760.25 ns 11.29 1653 KB 6.19
NSubstitute 1000 1,866,688.7 ns 12,119.15 ns 11,336.26 ns 12.70 1434.49 KB 5.38
FakeItEasy 1000 3,110,883.1 ns 67,112.91 ns 62,777.45 ns 21.17 4690.81 KB 17.58

CompleteWorkflowBenchmarks

✅ No changes in memory or relative performance (1 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Complete 967.6 ns → 860.0 ns (-11%) 2,872 B → 2,872 B 0.95× → 1.05× 2.90× → 2.88×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
Intel Xeon 6975P-C 3.62GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Complete Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 860.0 ns 14.23 ns 13.31 ns 1.00 2.8 KB 1.00
Imposter 898.8 ns 13.68 ns 12.80 ns 1.05 3.17 KB 1.13
TUnitMocks 2,477.6 ns 69.02 ns 64.56 ns 2.88 10.3 KB 3.67
Moq 200,554.9 ns 760.65 ns 711.51 ns 233.25 46.58 KB 16.61
NSubstitute 18,515.5 ns 641.00 ns 599.59 ns 21.53 37.13 KB 13.24
FakeItEasy 15,850.1 ns 251.42 ns 235.18 ns 18.43 34.36 KB 12.25

MockCreationBenchmarks

✅ No changes in memory or relative performance (1 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
CreateMock 15.7 ns → 15.6 ns (-1%) 136 B → 136 B 5.66× → 5.82× 1.67× → 1.70×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 7763 2.65GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

CreateMock Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 15.62 ns 0.651 ns 0.609 ns 1.00 136 B 1.00
Imposter 90.87 ns 2.003 ns 1.873 ns 5.83 504 B 3.71
TUnitMocks 26.57 ns 0.289 ns 0.270 ns 1.70 216 B 1.59
Moq 1,248.27 ns 10.991 ns 10.281 ns 80.02 2088 B 15.35
NSubstitute 1,870.00 ns 15.219 ns 13.491 ns 119.88 5032 B 37.00
FakeItEasy 1,533.91 ns 12.282 ns 11.489 ns 98.33 2755 B 20.26

@vbreuss
vbreuss disabled auto-merge November 18, 2026 15:01
@vbreuss
vbreuss merged commit da56746 into main Nov 18, 2026
41 of 42 checks passed
@vbreuss
vbreuss deleted the fix/httpclient-handler-member-ids branch November 18, 2026 15:01
github-actions Bot added a commit that referenced this pull request Nov 18, 2026
…eparately from those of its handler (#1023) by Valentin Breuß
github-actions Bot added a commit that referenced this pull request Nov 18, 2026
…eparately from those of its handler (#1023) by Valentin Breuß
@github-actions

Copy link
Copy Markdown

This is addressed in release v4.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant